package com.turing.merchant.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.turing.merchant.entity.CustomerGood;
import com.turing.merchant.service.CustomerGoodService;
import com.turing.merchant.mapper.CustomerGoodMapper;
import enums.ErrorCode;
import org.springframework.stereotype.Service;
import result.Result;

import java.util.List;
import java.util.Map;

/**
* @author 28123
* @description 针对表【customer_good(用户商品)】的数据库操作Service实现
* @createDate 2023-05-10 16:41:52
*/
@Service
public class CustomerGoodServiceImpl extends ServiceImpl<CustomerGoodMapper, CustomerGood>
    implements CustomerGoodService{

    @Override
    public Result cgList(String merchantName, String gdName, Integer priceType, String cusNickname, Integer pageNum, Integer pageSize) {
        if (pageNum!=null && pageSize!=null){
            PageHelper.startPage(pageNum,pageSize);
        }
        List<Map> list = baseMapper.cgList(merchantName,gdName,priceType,cusNickname,pageNum,pageSize);
        if (list.size() == 0){
            return Result.fail(ErrorCode.NODATA);
        }
        if (pageNum!=null && pageSize!=null){
            return Result.success(new PageInfo<>(list));
        }
        return Result.success(list);
    }
}




